package com.neu.activity;

import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;

import androidx.appcompat.app.AppCompatActivity;

import com.neu.R;

public class LoginActivity extends AppCompatActivity implements View.OnClickListener {

    private EditText txtUserName;
    private EditText txtPassWord;
    private Button btnLogin;
    private Button btnReg;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_login);
        initView();
    }

    private void initView() {
        txtUserName = (EditText) findViewById(R.id.txtUserName);
        txtPassWord = (EditText) findViewById(R.id.txtPassWord);
        btnLogin = (Button) findViewById(R.id.btnLogin);
        btnReg = (Button) findViewById(R.id.btnReg);

        btnLogin.setOnClickListener(this);
        btnReg.setOnClickListener(this);
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.btnLogin:

                break;
            case R.id.btnReg:

                break;
        }
    }

    private void submit() {
        // validate
        String txtUserNameString = txtUserName.getText().toString().trim();
        if (TextUtils.isEmpty(txtUserNameString)) {
            Toast.makeText(this, "txtUserNameString不能为空", Toast.LENGTH_SHORT).show();
            return;
        }

        String txtPassWordString = txtPassWord.getText().toString().trim();
        if (TextUtils.isEmpty(txtPassWordString)) {
            Toast.makeText(this, "txtPassWordString不能为空", Toast.LENGTH_SHORT).show();
            return;
        }

        // TODO validate success, do something


    }
}